<?php

namespace zhuli\test;

require __DIR__ . '/zhuli/core/DiInterface.php';
require __DIR__ . '/zhuli/core/Di.php';


//开始学习
// --------
class Pig
{

}

class BigPig
{
    public function __construct(Pig $pig)
    {

    }
}

interface SecondPigInterface
{
}

class SecondPig implements SecondPigInterface
{
    public $name;
    public $age;
    public $gender;
    public $language;
    public $test;

    public function __construct(Pig $pig, $name, $age, $language, $gender = '女', $test = '试试看')
    {
        $this->name = $name;
        $this->age = $age;
        $this->gender = $gender;
        $this->language = $language;
        $this->test = $test;
    }
}

// -------


$di = new \zhuli\core\Di();

$pig = $di->get('zhuli\test\Pig');
$pig2 = $di->get('zhuli\test\Pig');

var_dump($pig == $pig2);
var_dump($pig === $pig2);

$di->setSingleton('zhuli\test\Pig');

$pig = $di->get('zhuli\test\Pig');
$pig2 = $di->get('zhuli\test\Pig');

var_dump($pig == $pig2);
var_dump($pig === $pig2);

$bigPig = $di->get('zhuli\test\BigPig');
print_r($bigPig);

$di->set('zhuli\test\SecondPigInterface', 'zhuli\test\SecondPig');
$di->set('zhuli\test\SecondPig', [
    'name' => '珠砾',
    'age' => 30,
    'language'=>'闽南语'
]);
$secondPig = $di->get('zhuli\test\SecondPigInterface');
print_r($secondPig);






